package com.zk.yygh.rabbit.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: 张凯
 * @date: 2022/6/21 - 15:59
 */
//添加mq的业务方法
@Service
public class RabbitService {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    /**
     *  发送消息
     * @param exchange 交换机
     * @param routingKey 路由键
     * @param message 消息
     */
    public boolean sendMessage(String exchange, String routingKey, Object message) {
        System.out.println(rabbitTemplate);
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
        return true;
    }
}
